package com.funtl.framework.web.purview.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.funtl.framework.java.util.common.CommonBean;
import com.funtl.framework.java.util.exception.ServiceException;
import com.funtl.framework.java.web.orm.hibernate.dao.IHibernateDao;
import com.funtl.framework.java.web.orm.hibernate.param.HibernateParam;
import com.funtl.framework.web.entity.PurviewColumn;
import com.funtl.framework.web.purview.service.IPurviewColumnService;

@Component
public class PurviewColumnServiceImpl implements IPurviewColumnService {
	private IHibernateDao hibernateDao;

	//common service
	
	@Override
	public PurviewColumn get(PurviewColumn entity) throws ServiceException {
		HibernateParam param = new HibernateParam();
		param.setPropertyTypes(new String[] {"id"});
		param.setOperators(new String[] {"="});
		param.setPropertyValues(new String[] {entity.getId()});
		return hibernateDao.get(entity, param);
	}

	@Override
	public List<PurviewColumn> getList(PurviewColumn entity) throws ServiceException {
		return hibernateDao.getListByEhcatch(entity, "columnNo", "ASC");
	}

	@Override
	public String insert(PurviewColumn entity) throws ServiceException {
		hibernateDao.insert(entity);
		return null;
	}

	@Override
	public String delete(PurviewColumn entity) throws ServiceException {
		hibernateDao.delete(entity, "id");
		return null;
	}

	@Override
	public String update(PurviewColumn entity) throws ServiceException {
		PurviewColumn purviewColumn = get(entity);
		CommonBean.beanToBean(entity, purviewColumn);
		hibernateDao.update(entity);
		return null;
	}

	//getter setter
	
	public IHibernateDao getHibernateDao() {
		return hibernateDao;
	}

	@Resource
	public void setHibernateDao(IHibernateDao hibernateDao) {
		this.hibernateDao = hibernateDao;
	}

}
